import { createApp } from 'vue'
import App from './App.vue'
// import axios from 'axios'
// import VueAxios from 'vue-axios'
import router from './router/routes.js'
import store from './vuex/store.js'
import Antd from 'ant-design-vue'
import { message } from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'

// createApp(App).mount('#app')

let app = createApp(App);
app.config.productionTip = false;
app.use(Antd);
app.use(router);
app.use(store);
// app.use(VueAxios, axios);
// app.config.globalProperties.axios=axios
app.mount("#app");


router.beforeEach((to, from, next) => {

    //获取用户登录成功后储存的登录标志
    let getFlag = sessionStorage.getItem("Flag");

    //如果登录标志存在且为isLogin，即用户已登录
    if (getFlag === "loginType") {
        //设置vuex登录状态为已登录
        store.state.a.loginType = true
        next()

    } else {//如果登录标志不存在，即未登录

        //用户想进入需要登录的页面，则定向回登录界面
        if (to.meta.loginType) {
            next({
                path: "/"
            })
            //iViewUi友好提示
            message.info('请先登录')
            //用户进入无需登录的界面，则跳转继续
        } else {
            next()
        }

    }

});